<template>
    <div id="dialog">
       <el-dialog
  :title="DialogData.title"
  :visible.sync="DialogData.show"
  width="30%"
  >
  <div class="formData">
       <el-form :model="formData" status-icon  ref="ruleForm" label-width="100px" class="demo-ruleForm">
  <el-form-item label="姓名" prop="pass">
    <el-input  v-model="formData.username" autocomplete="off"></el-input>
  </el-form-item>
  <el-form-item label="联系号码" prop="checkPass">
    <el-input  v-model="formData.telephone" autocomplete="off"></el-input>
  </el-form-item>
  <el-form-item label="所在省市" prop="age">
    <el-input v-model="formData.address"></el-input>
  </el-form-item>
  <el-form-item label="邮箱" prop="age">
    <el-input v-model="formData.mailbox"></el-input>
  </el-form-item>

</el-form>
  </div>
  <span slot="footer" class="dialog-footer">
    <!-- <el-button @click="DialogData.show = false">取 消</el-button> -->
    <el-button type="primary" @click="subForm">立即申请</el-button>
  </span>
</el-dialog>
    </div>
</template>

<script>
    export default {
        props: {
            DialogData: Object,
            formData: Object
        },
        methods: {
            async subForm() {
                let { username, telephone, address, mailbox } = this.formData
                if (!username) {
                    this.$message.error("请输入姓名")
                    return false
                } else if (!telephone) {
                    this.$message.error("请输入手机号码")
                    return false
                } else if (!address) {
                    this.$message.error("请输入您的地址")
                    return false
                } else if (!mailbox) {
                    this.$message.error("请输入您的邮箱")
                    return false
                }  else {
                   let res = await this.$axios.post("/index/index/leave", this.formData)
                   //console.log(res);
                   let code = res.data.code
                   if (code == 202) {
                       this.$message.success("提交成功")
                       this.DialogData.show = false
                   } else {
                       this.$message.success("网络问题，请重试！")
                       this.DialogData.show = false
                   }
                }
            },
        },
    }
</script>

<style  scoped>

</style>